package com.ruoyi.factory.estimate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.factory.erp.domain.ErppersonInfo;
import com.ruoyi.factory.estimate.domain.EstimateRelationCode;
import com.ruoyi.factory.estimate.domain.Pjpsndocinfo;
import com.ruoyi.factory.estimate.service.IEstimateRelationCodeService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价管理 被评价人和评价人关系codeController
 * 
 * @author ljj
 * @date 2025-11-03
 */
@RestController
@RequestMapping("/system/pjrelationcode")
public class EstimateRelationCodeController extends BaseController
{
    @Autowired
    private IEstimateRelationCodeService estimateRelationCodeService;

    /**
     * 查询评价管理 被评价人和评价人关系code列表
     */
    @PreAuthorize("@ss.hasPermi('system:pjrelationcode:list')")
    @GetMapping("/list")
    public TableDataInfo list(EstimateRelationCode estimateRelationCode)
    {
        startPage();
        List<EstimateRelationCode> list = estimateRelationCodeService.selectEstimateRelationCodeList(estimateRelationCode);
        return getDataTable(list);
    }

    /**
     * 导出评价管理 被评价人和评价人关系code列表
     */
    @PreAuthorize("@ss.hasPermi('system:pjrelationcode:export')")
    @Log(title = "评价管理 被评价人和评价人关系code", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EstimateRelationCode estimateRelationCode)
    {
        List<EstimateRelationCode> list = estimateRelationCodeService.selectEstimateRelationCodeList(estimateRelationCode);
        ExcelUtil<EstimateRelationCode> util = new ExcelUtil<EstimateRelationCode>(EstimateRelationCode.class);
        util.exportExcel(response, list, "评价管理 被评价人和评价人关系code数据");
    }

    /**
     * 获取评价管理 被评价人和评价人关系code详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pjrelationcode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(estimateRelationCodeService.selectEstimateRelationCodeById(id));
    }

    /**
     * 新增评价管理 被评价人和评价人关系code
     */
    @PreAuthorize("@ss.hasPermi('system:pjrelationcode:add')")
    @Log(title = "评价管理 被评价人和评价人关系code", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EstimateRelationCode estimateRelationCode)
    {
        return toAjax(estimateRelationCodeService.insertEstimateRelationCode(estimateRelationCode));
    }

    /**
     * 修改评价管理 被评价人和评价人关系code
     */
    @PreAuthorize("@ss.hasPermi('system:pjrelationcode:edit')")
    @Log(title = "评价管理 被评价人和评价人关系code", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EstimateRelationCode estimateRelationCode)
    {
        return toAjax(estimateRelationCodeService.updateEstimateRelationCode(estimateRelationCode));
    }

    /**
     * 删除评价管理 被评价人和评价人关系code
     */
    @PreAuthorize("@ss.hasPermi('system:pjrelationcode:remove')")
    @Log(title = "评价管理 被评价人和评价人关系code", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(estimateRelationCodeService.deleteEstimateRelationCodeByIds(ids));
    }


    /**
     * @author: LiuJiaji
     * @date: 2025/11/5 15:52
     * @description: TODO 查询友空间人员信息
     * @param:
     * @return:
     **/
    @PreAuthorize("@ss.hasPermi('system:pjrelationcode:querypsndocinfo')")
    @GetMapping("/querypsndocinfo")
    public AjaxResult querypsndocinfo(ErppersonInfo erppersonInfo)
    {
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("value","bj");
        jsonObject.put("label","北京");
        JSONObject jsonObject2 = new JSONObject();
        jsonObject2.put("code","sh");
        jsonObject2.put("name","上海");
        jsonArray.add(jsonObject);
        jsonArray.add(jsonObject2);
        estimateRelationCodeService.querypsndocinfo(erppersonInfo);
        return new AjaxResult(200,"123",jsonArray);
    }
}
